<!--
 -
 - Licensed to the Apache Software Foundation (ASF) under one
 - or more contributor license agreements.  See the NOTICE file
 - distributed with this work for additional information
 - regarding copyright ownership.  The ASF licenses this file
 - to you under the Apache License, Version 2.0 (the
 - "License"); you may not use this file except in compliance
 - with the License.  You may obtain a copy of the License at
 -
 -   http://www.apache.org/licenses/LICENSE-2.0
 -
 - Unless required by applicable law or agreed to in writing,
 - software distributed under the License is distributed on an
 - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 - KIND, either express or implied.  See the License for the
 - specific language governing permissions and limitations
 - under the License.
 -
 -->
<div class="dijitHidden">
    <div data-dojo-type="dijit.Dialog" data-dojo-props="title:'Port'" id="addPort">
        <form id="formAddPort" method="post" data-dojo-type="dijit.form.Form">
            <div class="hidden infoMessage" id="portEditWarning">NOTE: changes will only take effect after Broker restart.</div>
            <div id="formAddPort:fields">

                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.name">Name*:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.name" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                                name: 'name',
                                required: 'true',
                                placeHolder: 'name',
                                promptMessage: 'Name of port, must be unique',
                                title: 'Enter name of port'"/>
                    </div>
                </div>

                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.type">Port Type*:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <select id="formAddPort.type"
                                data-dojo-type="dijit.form.FilteringSelect"
                                data-dojo-props="
                                    name: 'type',
                                    label: 'Port Type*:',
                                    value: '',
                                    placeHolder: 'port type',
                                    promptMessage: 'Port type',
                                    title: 'Enter port type'">
                        </select>
                    </div>
                </div>

                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.port">Port Number*:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.port" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                                name: 'port',
                                required: 'true',
                                placeHolder: 'port number',
                                promptMessage: 'Port number to be bound',
                                title: 'Enter port number'"/>
                    </div>
                </div>
            </div>

            <div id="formAddPort:fieldsProtocols">
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.protocols">Protocols:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <select id="formAddPort.protocols"
                                data-dojo-type="dijit.form.MultiSelect"
                                data-dojo-props="
                                    name: 'protocols',
                                    value: '',
                                    title: 'Select protocol(s) to be associated with this port'">
                        </select>
                    </div>
                    <div id="formAddPort.protocols.tooltip"
                         data-dojo-type="dijit.Tooltip"
                         data-dojo-props="connectId: 'formAddPort.protocols',
                                          label: 'Protocol(s) to be associated with the port'">
                    </div>

                </div>
            </div>

            <div id="formAddPort:fieldsAuthenticationProvider">
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.authenticationProvider">Authentication Provider*:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <select id="formAddPort.authenticationProvider"
                                data-dojo-type="dijit.form.FilteringSelect"
                                data-dojo-props="
                            name: 'authenticationProvider',
                            searchAttr: 'name',
                            required: true,
                            placeHolder: 'provider',
                            promptMessage: 'Authentication provider to authenticate users connecting to the port',
                            title: 'Associate the port with an authentication provider'">
                        </select>
                    </div>
                </div>
            </div>

            <div id="formAddPort:fieldsBindingAddress">
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.bindingAddress">Binding address:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.bindingAddress" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                            name: 'bindingAddress',
                            placeHolder: 'binding address',
                            promptMessage: 'Restricts the port to listen on the specified address only. The <code>*</code> wildcard signifies all addresses',
                            title: 'Enter a binding address'"/>
                    </div>
                </div>
            </div>

            <div id="formAddPort:transport" >
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.transports">Transport:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <select id="formAddPort.transports"
                                data-dojo-type="dijit.form.MultiSelect"
                                data-dojo-props="
                                    name: 'transports',
                                    placeHolder: 'TCP',
                                    value: '',
                                    multiple: true,
                                    title: 'Select transport(s) to be associated with the port'">
                        </select>
                        <div id="formAddPort.transports.tooltip"
                             data-dojo-type="dijit.Tooltip"
                             data-dojo-props="connectId: 'formAddPort.transports',
                                              label: 'Transport(s) to be associated with the port'">
                        </div>
                    </div>
                </div>
            </div>

            <div id="formAddPort:maxOpenConnections" >
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.transports">Maximum number of connections:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.maxOpenConnections" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                            name: 'maxOpenConnections',
                            placeHolder: 'maximum number of connections',
                            promptMessage: 'Maximum number of concurrent connections permitted by this port. The <code>-1</code> signifies no limit is imposed.',
                            title: 'Enter a maximum number of connections'"/>
                    </div>
                </div>
            </div>

            <div id="formAddPort:threadPoolMinMaxSettings" >
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.transports">Minimum number of connection threads:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.threadPoolMinimum" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                            name: 'threadPoolMinimum',
                            placeHolder: 'minimum number of connection threads',
                            promptMessage: 'Minimum number of connection threads used to serve client connections on this port.',
                            title: 'Enter a minimum number of connection threads'"/>
                    </div>
                </div>
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.transports">Maximum number of connection threads:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.threadPoolMaximum" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                            name: 'threadPoolMaximum',
                            placeHolder: 'maximum number of connection threads',
                            promptMessage: 'Maximum number of connection threads used to serve client connections on this port.',
                            title: 'Enter a maximum number of connection threads'"/>
                    </div>
                </div>
            </div>

            <div id="formAddPort:threadPoolSizeSettings" >
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.transports">Number of connection threads:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <input id="formAddPort.threadPoolSize" type="text"
                               data-dojo-type="dijit.form.ValidationTextBox"
                               data-dojo-props="
                            name: 'threadPoolSize',
                            placeHolder: 'number of connection threads',
                            promptMessage: 'Number of connection threads used to serve client connections on this port.',
                            title: 'Enter a number of connection threads'"/>
                    </div>
                </div>
            </div>

            <div id="formAddPort:fieldsTransportSSL">
                <div class="clear">
                    <div class="formLabel-labelCell">
                        <label for="formAddPort.keyStore">Key Store*:</label>
                    </div>
                    <div class="formLabel-controlCell">
                        <select id="formAddPort.keyStore"
                                data-dojo-type="dijit.form.FilteringSelect"
                                data-dojo-props="
                                    name: 'keyStore',
                                    label: 'Key Store*:',
                                    searchAttr: 'name',
                                    placeHolder: 'keystore',
                                    value: '',
                                    required: true,
                            promptMessage: 'Keystore that provides the SSL certificate',
                            title: 'Select the keystore that provides the SSL certificate'">
                        </select>
                    </div>
                </div>
            </div>

            <div id="formAddPort:fieldsClientAuth">
                <div id="formAddPort:fieldsClientAuthCheckboxes">
                    <div class="clear">
                        <div class="formLabel-labelCell">
                            <label for="formAddPort.needClientAuth">Need SSL Client Certificate:</label>
                        </div>
                        <div class="formLabel-controlCell">
                            <input id="formAddPort.needClientAuth" type="checkbox"
                                   data-dojo-type="dijit.form.CheckBox"
                                   data-dojo-props="
                                    name: 'needClientAuth'" />
                        </div>
                    </div>
                    <div class="clear">
                        <div class="formLabel-labelCell">
                            <label for="formAddPort.wantClientAuth">Want SSL Client Certificate:</label>
                        </div>
                        <div class="formLabel-controlCell">
                            <input id="formAddPort.wantClientAuth" type="checkbox"
                                   data-dojo-type="dijit.form.CheckBox"
                                   data-dojo-props="
                            name: 'wantClientAuth'" />
                        </div>
                    </div>
                </div>

                <div class="clear">
                    <div class="formLabel-labelCell">
                        Trust Stores:
                    </div>
                </div>

                <div class="clear">
                    <div class="formLabel-controlCell">
                        <table id="formAddPort.trustStores"
                               data-dojo-type="dojox.grid.EnhancedGrid"
                               data-dojo-props="
                                plugins: {indirectSelection: true},
                                rowSelector:'0px'"
                               style="height: 100px; width:400px"> <!--todo remove -->
                            <thead>
                                <tr>
                                    <th field="name">Name</th>
                                    <th field="peersOnly">Peers Only</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>

            <input type="hidden" id="formAddPort.id" name="id"/>
            <div class="clear"></div>
            <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar">
                <!-- submit buttons -->
                <input type="submit" value="Save Port" label="Save Port" dojoType="dijit.form.Button" />
            </div>
        </form>
    </div>
</div>
